package com.xjw.adapte {
	import com.bases.TUIComponent;

	/**
	 * 部局控制器(可以算出,当前要在原来的比例(如果太大,就同比缩放))
	 * @author pethan
	 *
	 */
	public class AdapteControl {
		private static var maxPercent:Number = -100000;

		public function AdapteControl(){
		}

		/**
		 * 自适应部局
		 * @param target 要部局的对象
		 * @param totalWidth 总的宽度
		 * @param totalHeight 总的高度
		 * @param wPercent target要占用的比例宽度 取值空间为(0-100)
		 * @param hPercent target要占用的比例高度 取值空间为(0-100)
		 * @param xPercent  x的比例坐标 取值空间为(0-100)
		 * @param yPercent  y的比例坐标 取值空间为(0-100)
		 *
		 */
		public static function adapteComponet(target:TUIComponent, totalWidth:Number, totalHeight:Number, wPercent:Number, hPercent:Number, xPercent:Number, yPercent:Number):void {
			target.scaleX = target.scaleY = 1;
			target.x = totalWidth * xPercent / 100;
			target.y = totalHeight * yPercent / 100;
			//求出是否需要等比缩放
			var targetWidth:Number = totalWidth * wPercent / 100;
			var targetHeight:Number = totalHeight * hPercent / 100;
			var scalePercentX:Number = 1;
			var scalePercentY:Number = 1;
			if (targetWidth < target.width){
				scalePercentX = targetWidth / target.width;
			}
			if (targetHeight < target.height){
				scalePercentY = targetHeight / target.height;
			}
			var scalePercent:Number = 1;
			if (scalePercentX > scalePercentY){
				scalePercent = scalePercentY;
			} else {
				scalePercent = scalePercentX;
			}
			if (scalePercent != 1){
				target.scaleX = scalePercent;
				target.scaleY = scalePercent;
				//坐标要反向算出位置
				target.x = target.x / scalePercent;
				target.y = target.y / scalePercent;
			}
		}
	}
}

class SingleStance {
}